﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BCGC.BLL.Helper;
using BCGC.BLL.BusinessObject.UserAccount;

public partial class Admin_User_UserDetail : AdminBasePage
{
    private int Id
    {
        get
        {
            if (ViewState["Id"] == null)
                ViewState["Id"] = 0;
            return (int)ViewState["Id"];
        }
        set { ViewState["Id"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = Id = 0;
            if (!string.IsNullOrEmpty(Request.QueryString["id"]) && int.TryParse(Request.QueryString["id"], out id))
            {
                Id = id;
                LoadData();
            }
            else
                Response.Redirect(CustomSiteMap.Users);
        }
    }

    private void LoadData()
    {
        SiteUser user = SiteUser.GetUserById(Id, true);
        if (user == null)
            Response.Redirect(CustomSiteMap.Users);
        else
        {
            if (user.Profile != null)
            {
                lblRealName.Text = user.Profile.RealName;
                lblNickName.Text = user.Profile.NickName;
                lblCity.Text = user.Profile.City;
                lblDateOfBirth.Text = user.Profile.DateOfBirth.ToShortDateString();
                lblMessenger.Text = user.Profile.Messenger;
                lblFacebookProfileUrl.Text = user.Profile.FacebookProfileUrl;
                lblMood.Text = user.Profile.Mood;
                lblPlayerStyle.Text = user.Profile.PlayerStyle;
                lblElement.Text = user.Profile.Element;
                imgRealImage.ImageUrl = user.Profile.RealImageUrl;
                lblRealImageVerified.Text = user.Profile.IsRealImageVerified ? "Verified" : "Not verified";
                imgAvatarImage.ImageUrl = user.Profile.AvatarImageUrl;
                lblAvatarImageVerified.Text = user.Profile.IsAvatarImageVerified ? "Verified" : "Not verified";
                lblFavoriteGames.Text = user.Profile.FavoriteGames;
                lblBiography.Text = user.Profile.UserBio;
                lblUseProfileImage.Text = user.Profile.UseProfileImage ? "Yes" : "No";
            }

            lblUsername.Text = user.Username;
            lblEmail.Text = user.Email;
            lblRegisterDate.Text = user.CreateDateTime.ToShortDateString();
            lblInvalidLoginCount.Text = user.InvalidLoginCount.ToString();
            lblLastLogin.Text = user.LastLoginTime.ToShortDateString();
            lblOnline.Text = user.IsOnline ? "Online" : "Offline";
            lblLocked.Text = user.IsLocked ? "Locked" : "Not Locked";
            lblActivated.Text = user.IsActivated ? "Activated" : "Not Activated";
            lblVerificationCode.Text = user.VerificationCode;
            lblSecretQuestion.Text = user.SecretQuestion;
            lblSecretAnswer.Text = user.SecretAnswer;
        }
    }
}
